package com.test.spring.factory;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/9/26 21:36
 * <p>
 * 实例工厂方法：实例工厂的方法，即需要先创建工厂本身，再调用工厂的实例方法来返回bean的实例
 */
public class InstanceCarFactory {
    private Map<String, Car> cars;

    public InstanceCarFactory() {
        this.cars = new HashMap<>();
        cars.put("audi", new Car("audi", 300000));
        cars.put("ford", new Car("ford", 500000));
    }

    //静态工厂方法
    public Car getCar(String name) {
        return cars.get(name);
    }
}
